﻿using FlyingEye.Models;
using FlyingEye.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;

namespace FlyingEye.Controllers
{
    /// <summary>
    /// 切刀服务控制器
    /// </summary>
    [ApiController]
    [Route("[controller]/[action]")]
    public class CutterServiceController : AbpController
    {
        private readonly ICutterService _cutterService;

        private readonly ILogger<CutterServiceController> _logger;

        public CutterServiceController(ICutterService cutterService, ILogger<CutterServiceController> logger)
        {
            _cutterService = cutterService;
            _logger = logger;
        }

        /// <summary>
        /// 记录切刀信息
        /// </summary>
        /// <param name="information">切刀信息</param>
        [HttpPost]
        public async Task<DefaultActionResult> RecordCutterInfo(CutterInformation information)
        {
            try
            {

                await _cutterService.RecordCutterInfoAsync(information);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "记录切刀消息异常。");
                return DefaultActionResult.GetFailureResult("记录切刀消息异常。");
            }

            return DefaultActionResult.GetSuccessResult();
        }
    }
}
